package com.efesco.finance.gathering;

import java.util.List;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * changeInvoiceStatusViewModel
 */
public class changeInvoiceStatusViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
    // Add your code here
	  Dataset invoiceDataset = getDataset("invoiceDataset");
	  String invoiceId=invoiceDataset.getString("INVOICE_ID");
	  String ifEffect=invoiceDataset.getString("IF_EFFECT");	  
      super.doUpdateData(parameters, outParameters);
      if (ifEffect.equals("2"))  {
    	  DBStatement statement = new DBStatement();
    	  String sql="delete from s_actual_receive_adjust where actual_receive_adjust_id in " +
    	  		"( select a.actual_receive_adjust_id from s_invoice i,s_hr_invoice_detail h,s_ought_receive o," +
    	  		"s_actual_receive_adjust a where i.invoice_id=h.invoice_id and i.single_company_id=o.single_company_id " +
    	  		"and h.ought_month=o.ought_month and o.ought_receive_id=a.ought_receive_id and h.rate_odds<>0 and " +
    	  		"i.invoice_id='"+invoiceId+"')";
    	  statement.setSql(sql);
          statement.execute();
          statement.close();
      }     
    
  }

}
